import { observable, action, autorun, toJS } from 'mobx';
import * as  Apis from '../apis/govern';
import objectAssign from 'object-assign';
import { WeaTools, WeaLocaleProvider } from 'ecCom';
import { message, Icon } from 'antd';
import { WeaForm } from 'comsMobx';
import _ from "lodash";
const getLabel = WeaLocaleProvider.getLabel;

export class ModalConfirmStore {
    @observable confirmVisible = false;
    @action
    handleModalConfirm = (bool, type, id, params = {}) => {
        this.confirmVisible = bool;
    }
    constructor(props) {

    }
    //完结
    @action
    finishTask(params) {
        Apis.finishTask(params).then(data => {
            if(parseInt(data.status) == 1){
              message.success(`${getLabel('16634,84565','确认成功！')}`);
            }else{
              message.error(data.error);
            }
        }).catch(error => {
            message.error(error);
        });
    }
    //批量下发
    @action
    distributeAll(params) {
        Apis.distributeAll(params).then(data => {
          if(parseInt(data.status) == 1){
            message.success(`${getLabel('16634,84565','确认成功！')}`);
          }else{
            message.error(data.error);
          }
        }).catch(error => {
            message.error(error);
        });
    }

    //批量下发
    @action
    distribute(params) {
        Apis.distribute(params).then(data => {
            if(parseInt(data.status) == 1){
              message.success(`${getLabel('16634,84565','确认成功！')}`);
            }else{
              message.error(data.error);
            }
        }).catch(error => {
            message.error(error);
        });
    }

    @action
    subBtn(id, modelType) {
        let newParams = { ...{ taskid: id } };
        /*switch (modelType) {
            case "finishTask":
                this.finishTask(newParams)
                break;
            case "distributeAll":
                this.distributeAll(newParams)
                break;
            case "distribute":
                this.distribute(newParams)
                break;
            default:
                return false
        }*/
    }

}
